﻿using System;
using System.ComponentModel;
using System.Linq;
using ProjectEuler.Linq;

namespace ProjectEuler.Problems
{
    [EulerProblem(3, 6857)]
    [Description("Find the largest prime factor of a composite number.")]
    internal sealed class Problem003 : EulerProblem
    {
        public override Object Solve()
        {
            var product = 600851475143;
            var sqrt = Math.Sqrt(product);

            return new SieveOfEratosthenes((Int32)(sqrt))
                .Where(f => product.IsMultipleOf(f))
                .Max();
        }
    }
}
